# """ 分页获取数据
# @Project: Rebar
# @File: pagination_mapper.py
# @Author: hzc
# @Date: 2023/3/29 14:32
# """
# from typing import List
#
# from sqlalchemy.ext.declarative import declarative_base
#
# from model.db import rebar, TbUser, TbLog, TbCompany, TbOrders, TbOrderDetails
#
#
# def get_data_pagination(tb: declarative_base, page_num, page_size) -> List[declarative_base]:
#     """
#     分页获取数据
#     :param tb: 数据表
#     :param page_num:
#     :param page_size:
#     :return:
#     """
#     try:
#         query = rebar.query(tb)
#         offset = (page_num - 1) * page_size  # 计算偏移量
#         # if order_by == OrderByEnum.asc:  # 排序
#         #     query = query.order_by(TbLog.created_time.asc())
#         # elif order_by == OrderByEnum.desc:
#         #     query = query.order_by(TbLog.created_time.desc())
#         query = query.offset(offset).limit(page_size)  # 分页
#         data = query.all()  # 获取分页数据
#         return data
#     except Exception as e:
#         print("log_mapper.py", e, e.__traceback__.tb_lineno)
#         raise e
#
#
# def get_users(page_num, page_size):  # 分页获取用户数据
#     return get_data_pagination(TbUser, page_num, page_size)
#
#
# def get_logs(page_num, page_size):  # 分页获取日志数据
#     return get_data_pagination(TbLog, page_num, page_size)
#
#
# def get_companies(page_num, page_size):  # 分页获取公司数据
#     return get_data_pagination(TbCompany, page_num, page_size)
#
#
# def get_orders(page_num, page_size):  # 分页获取订单数据
#     orders = get_data_pagination(TbOrders, page_num, page_size)
#     if not orders:
#         return None
#     for i in range(len(orders)):
#         # print("sss")
#         order_details = rebar.query(TbOrderDetails).filter_by(order_id=orders[i].order_id).all()
#         orders[i].order_details = order_details if order_details else []
#     return orders
